home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Peter Lewis / PNL Libraries / MyAssertions.p < prev    next >
Encoding:
Text File  |  1994-09-30  |  927 b   |  54 lines  |  [TEXT/PJMM]

  1. unit MyAssertions;
  2.  
  3. interface
  4.  
  5. {$IFC undefined THINK_Pascal}
  6.     uses
  7.         Types;
  8. {$ENDC}
  9.  
  10.     procedure Assert (b: boolean);
  11.     procedure AssertValidPtr (p: univ ptr);
  12.     procedure AssertValidPtrNil (p: univ ptr);
  13.     procedure AssertValidHandle (h: univ handle);
  14.     procedure AssertValidHandleNil (h: univ handle);
  15.  
  16. implementation
  17.  
  18. {$IFC undefined THINK_Pascal}
  19.     uses
  20.         Memory;
  21. {$ENDC}
  22.  
  23.     procedure Assert (b: boolean);
  24.     begin
  25.         if not b then begin
  26.             DebugStr('Assert Failed;sc;hc');
  27.         end;
  28.     end;
  29.  
  30.     procedure AssertValidPtr (p: univ ptr);
  31.     begin
  32.         Assert((p <> nil) & (not odd(ord(p))));
  33.     end;
  34.  
  35.     procedure AssertValidPtrNil (p: univ ptr);
  36.     begin
  37.         if p <> nil then
  38.             AssertValidPtr(p);
  39.     end;
  40.  
  41.     procedure AssertValidHandle (h: univ handle);
  42.     begin
  43.         AssertValidPtr(h);
  44.         AssertValidPtr(h^);
  45.         Assert(RecoverHandle(h^) = h);
  46.     end;
  47.  
  48.     procedure AssertValidHandleNil (h: univ handle);
  49.     begin
  50.         if h <> nil then
  51.             AssertValidHandle(h);
  52.     end;
  53.  
  54. end.